package com.micangcaihang.micang.view;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.micangcaihang.common.utils.ToastUtils;
import com.micangcaihang.micang.R;
import com.micangcaihang.micang.entity.MatesChooseListBean;
import com.micangcaihang.micang.entity.MatesEntity;
import com.micangcaihang.micang.entity.MatesRequest;
import com.micangcaihang.micang.entity.PickerEntity;
import com.micangcaihang.micang.view.mvp.contract.MatesContract;
import com.micangcaihang.micang.view.mvp.presenter.MatesPresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * <pre>
 *     author : Fandy
 *     e-mail : fandayongfly@gmail.com
 *     time   : 2017/8/8
 *     update : 2017/8/8
 *     desc   : MiCang
 *     version: 1.0
 * </pre>
 */
public class RecyclerMatesLayout extends LinearLayout implements MatesContract.View {
    @BindView(R.id.tv_married_title)
    TextView mTvMarriedTitle;
    @BindView(R.id.et_married_customer_name)
    EditText mEtMarriedCustomerName;
    @BindView(R.id.tv_married_customer_sex)
    TextView mTvMarriedCustomerSex;
    @BindView(R.id.tv_married_certificate_type)
    TextView mTvMarriedCertificateType;
    @BindView(R.id.et_married_certificate_number)
    EditText mEtMarriedCertificateNumber;
    @BindView(R.id.tv_married_peason_credit)
    TextView mTvMarriedPeasonCredit;
    @BindView(R.id.tv_married_peason_crediless)
    TextView mTvMarriedPeasonCrediless;
    @BindView(R.id.tv_married_peason_enforced)
    TextView mTvMarriedPeasonEnforced;
    @BindView(R.id.et_married_mobile_phone)
    EditText mEtMarriedMobilePhone;
    @BindView(R.id.lly_married)
    LinearLayout mLlyMarried;
    @BindView(R.id.tv_current_title)
    TextView mTvCurrentTitle;
    @BindView(R.id.et_current_customer_name)
    EditText mEtCurrentCustomerName;
    @BindView(R.id.tv_current_customer_sex)
    TextView mTvCurrentCustomerSex;
    @BindView(R.id.tv_current_certificate_type)
    TextView mTvCurrentCertificateType;
    @BindView(R.id.et_current_certificate_number)
    EditText mEtCurrentCertificateNumber;
    @BindView(R.id.tv_current_peason_credit)
    TextView mTvCurrentPeasonCredit;
    @BindView(R.id.tv_current_peason_crediless)
    TextView mTvCurrentPeasonCrediless;
    @BindView(R.id.tv_current_peason_enforced)
    TextView mTvCurrentPeasonEnforced;
    @BindView(R.id.et_current_mobile_phone)
    EditText mEtCurrentMobilePhone;
    @BindView(R.id.tv_predecessor_title)
    TextView mTvPredecessorTitle;
    @BindView(R.id.et_predecessor_customer_name)
    EditText mEtPredecessorCustomerName;
    @BindView(R.id.tv_predecessor_customer_sex)
    TextView mTvPredecessorCustomerSex;
    @BindView(R.id.tv_predecessor_certificate_type)
    TextView mTvPredecessorCertificateType;
    @BindView(R.id.et_predecessor_certificate_number)
    EditText mEtPredecessorCertificateNumber;
    @BindView(R.id.tv_predecessor_peason_credit)
    TextView mTvPredecessorPeasonCredit;
    @BindView(R.id.tv_predecessor_peason_crediless)
    TextView mTvPredecessorPeasonCrediless;
    @BindView(R.id.tv_predecessor_peason_enforced)
    TextView mTvPredecessorPeasonEnforced;
    @BindView(R.id.et_predecessor_mobile_phone)
    EditText mEtPredecessorMobilePhone;
    @BindView(R.id.lly_remarry)
    LinearLayout mLlyRemarry;
    @BindView(R.id.tv_divorced_title)
    TextView mTvDivorcedTitle;
    @BindView(R.id.et_divorced_customer_name)
    EditText mEtDivorcedCustomerName;
    @BindView(R.id.tv_divorced_customer_sex)
    TextView mTvDivorcedCustomerSex;
    @BindView(R.id.tv_divorced_certificate_type)
    TextView mTvDivorcedCertificateType;
    @BindView(R.id.et_divorced_certificate_number)
    EditText mEtDivorcedCertificateNumber;
    @BindView(R.id.tv_divorced_peason_credit)
    TextView mTvDivorcedPeasonCredit;
    @BindView(R.id.tv_divorced_peason_crediless)
    TextView mTvDivorcedPeasonCrediless;
    @BindView(R.id.tv_divorced_peason_enforced)
    TextView mTvDivorcedPeasonEnforced;
    @BindView(R.id.et_divorced_mobile_phone)
    EditText mEtDivorcedMobilePhone;
    @BindView(R.id.lly_divorced)
    LinearLayout mLlyDivorced;
    @BindView(R.id.tv_wid_title)
    TextView mTvWidTitle;
    @BindView(R.id.et_wid_customer_name)
    EditText mEtWidCustomerName;
    @BindView(R.id.tv_wid_customer_sex)
    TextView mTvWidCustomerSex;
    @BindView(R.id.tv_wid_certificate_type)
    TextView mTvWidCertificateType;
    @BindView(R.id.et_wid_certificate_number)
    EditText mEtWidCertificateNumber;
    @BindView(R.id.tv_wid_death_certificate_type)
    TextView mTvWidDeathCertificateType;
    @BindView(R.id.lly_wid)
    LinearLayout mLlyWid;
    private int mType;
    private Context mContext;
    private View mView;
    private String titleType;
    private List<MatesEntity> mMatesEntities;
//    private List<MatesRequest> mMatesRequests;
//    private MatesRequest mMarriedCurrentRequest;
//    private MatesRequest mRemarryCurrentRequest;
//    private MatesRequest mRemarrypredecessorRequest;
//    private MatesRequest mDivorcedRequest;
//    private MatesRequest mWidRequest;
    private MatesEntity mMarriedCurrent;
    private MatesEntity mRemarryCurrent;
    private MatesEntity mRemarrypredecessor;
    private MatesEntity mDivorced;
    private MatesEntity mWid;
    private MatesPresenter mPresenter;
    private int pickerType;
    private TextWatcher mTextChangeListener101;
    private TextWatcher mTextChangeListener102;
    private TextWatcher mTextChangeListener103;

    private TextWatcher mTextChangeListener201;
    private TextWatcher mTextChangeListener202;
    private TextWatcher mTextChangeListener203;

    private TextWatcher mTextChangeListener301;
    private TextWatcher mTextChangeListener302;
    private TextWatcher mTextChangeListener303;

    private TextWatcher mTextChangeListener401;
    private TextWatcher mTextChangeListener402;
    private TextWatcher mTextChangeListener403;

    private TextWatcher mTextChangeListener501;
    private TextWatcher mTextChangeListener502;

    public RecyclerMatesLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MatesTitle);
        int titleType = typedArray.getInteger(R.styleable.MatesTitle_titleType, 1);
        typedArray.recycle();
        switch (titleType) {
            case 1:
                this.titleType = "借款人";
                break;
            case 2:
                this.titleType = "共有人";
                break;
            case 3:
                this.titleType = "实际用款人";
                break;
            case 4:
                this.titleType = "共借人";
                break;
        }
        initView();
        mMatesEntities = new ArrayList<>();
//        mMatesRequests = new ArrayList<>();

//        mMarriedCurrentRequest = new MatesRequest("1");
//        mRemarryCurrentRequest = new MatesRequest("1");
//        mRemarrypredecessorRequest = new MatesRequest("2");
//        mDivorcedRequest = new MatesRequest("2");
//        mWidRequest = new MatesRequest("3");
        mMarriedCurrent = new MatesEntity("1");
        mRemarryCurrent = new MatesEntity("1");
        mRemarrypredecessor = new MatesEntity("2");
        mDivorced = new MatesEntity("2");
        mWid = new MatesEntity("3");
        mPresenter = new MatesPresenter(this);
    }

    public int getType() {
        return mType;
    }

    public void setType(int type) {
        mType = type;
        switch (mType) {
            case 1:
                mLlyMarried.setVisibility(GONE);
                mLlyRemarry.setVisibility(GONE);
                mLlyDivorced.setVisibility(GONE);
                mLlyWid.setVisibility(GONE);
                break;
            case 2:
                mLlyMarried.setVisibility(VISIBLE);
                mLlyRemarry.setVisibility(GONE);
                mLlyDivorced.setVisibility(GONE);
                mLlyWid.setVisibility(GONE);
                break;
            case 3:
                mLlyMarried.setVisibility(GONE);
                mLlyRemarry.setVisibility(VISIBLE);
                mLlyDivorced.setVisibility(GONE);
                mLlyWid.setVisibility(GONE);
                break;
            case 4:
                mLlyMarried.setVisibility(GONE);
                mLlyRemarry.setVisibility(GONE);
                mLlyDivorced.setVisibility(VISIBLE);
                mLlyWid.setVisibility(GONE);
                break;
            case 5:
                mLlyMarried.setVisibility(GONE);
                mLlyRemarry.setVisibility(GONE);
                mLlyDivorced.setVisibility(GONE);
                mLlyWid.setVisibility(VISIBLE);
                break;
            default:
                mLlyMarried.setVisibility(GONE);
                mLlyRemarry.setVisibility(GONE);
                mLlyDivorced.setVisibility(GONE);
                mLlyWid.setVisibility(GONE);
                break;
        }
    }

    public void setMatesEntities(List<MatesEntity> matesEntities) {
        mMatesEntities = matesEntities;
        mEtMarriedCustomerName.removeTextChangedListener((TextChangeListener101) mEtMarriedCustomerName.getTag());
        mEtMarriedCertificateNumber.removeTextChangedListener((TextChangeListener102) mEtMarriedCertificateNumber.getTag());
        mEtMarriedMobilePhone.removeTextChangedListener((TextChangeListener103) mEtMarriedMobilePhone.getTag());

        mEtCurrentCustomerName.removeTextChangedListener((TextChangeListener201) mEtCurrentCustomerName.getTag());
        mEtCurrentCertificateNumber.removeTextChangedListener((TextChangeListener202) mEtCurrentCertificateNumber.getTag());
        mEtCurrentMobilePhone.removeTextChangedListener((TextChangeListener203) mEtCurrentMobilePhone.getTag());

        mEtPredecessorCustomerName.removeTextChangedListener((TextChangeListener301) mEtPredecessorCustomerName.getTag());
        mEtPredecessorCertificateNumber.removeTextChangedListener((TextChangeListener302) mEtPredecessorCertificateNumber.getTag());
        mEtPredecessorMobilePhone.removeTextChangedListener((TextChangeListener303) mEtPredecessorMobilePhone.getTag());

        mEtDivorcedCustomerName.removeTextChangedListener((TextChangeListener401) mEtDivorcedCustomerName.getTag());
        mEtDivorcedCertificateNumber.removeTextChangedListener((TextChangeListener402) mEtDivorcedCertificateNumber.getTag());
        mEtDivorcedMobilePhone.removeTextChangedListener((TextChangeListener403) mEtDivorcedMobilePhone.getTag());

        mEtWidCustomerName.removeTextChangedListener((TextChangeListener501) mEtWidCustomerName.getTag());
        mEtWidCertificateNumber.removeTextChangedListener((TextChangeListener502) mEtWidCertificateNumber.getTag());

        setRequest(mMatesEntities);
    }

    private void setRequest(List<MatesEntity> matesEntities) {
        for (int i = 0; i < matesEntities.size(); i++) {
            MatesEntity matesEntity = matesEntities.get(i);
            MatesChooseListBean choose_list = matesEntity.getChoose_list();
            String relationship_type = matesEntity.getRelationship_type();
            if ("1".equals(relationship_type)) {//现任
                switch (mType) {
                    case 2://已婚现任
//                        String[] excludsArray = new String[]{"choose_list", "id"};
//                        try {
//                            Properties.copyPropertiesExclude(matesEntity, mMarriedCurrentRequest, excludsArray);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                        mMarriedCurrent = matesEntity;
                        //姓名
                        mEtMarriedCustomerName.setText(matesEntity.getCustomer_name());
                        //证件号码
                        mEtMarriedCertificateNumber.setText(matesEntity.getCertificate_number());
                        //证件号码
                        mEtMarriedMobilePhone.setText(matesEntity.getMobile_phone());
                        //性别
                        mTvMarriedCustomerSex.setText(choose_list.getCustomer_sex());
                        //证件类型
                        mTvMarriedCertificateType.setText(choose_list.getCertificate_type());
                        //征信状况
                        mTvMarriedPeasonCredit.setText(choose_list.getPeason_credit());
                        //是否失信
                        mTvMarriedPeasonCrediless.setText(choose_list.getPeason_crediless());
                        //是否被执行
                        mTvMarriedPeasonEnforced.setText(choose_list.getPeason_enforced());
//                        if (!mMatesRequests.contains(mMarriedCurrentRequest)) {
//                            mMatesRequests.add(mMarriedCurrentRequest);
//                        }
                        mTextChangeListener101 = new TextChangeListener101(matesEntity);
                        mTextChangeListener102 = new TextChangeListener102(matesEntity);
                        mTextChangeListener103 = new TextChangeListener103(matesEntity);
                        mEtMarriedCustomerName.addTextChangedListener(mTextChangeListener101);
                        mEtMarriedCertificateNumber.addTextChangedListener(mTextChangeListener102);
                        mEtMarriedMobilePhone.addTextChangedListener(mTextChangeListener103);
                        mEtMarriedCustomerName.setTag(mTextChangeListener101);
                        mEtMarriedCertificateNumber.setTag(mTextChangeListener102);
                        mEtMarriedMobilePhone.setTag(mTextChangeListener103);
                        break;
                    case 3://再婚现任
//                        excludsArray = new String[]{"choose_list", "id"};
//                        try {
//                            Properties.copyPropertiesExclude(matesEntity, mRemarryCurrentRequest, excludsArray);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                        mRemarryCurrent = matesEntity;
                        //姓名
                        mEtCurrentCustomerName.setText(matesEntity.getCustomer_name());
                        //证件号码
                        mEtCurrentCertificateNumber.setText(matesEntity.getCertificate_number());
                        //证件号码
                        mEtCurrentMobilePhone.setText(matesEntity.getMobile_phone());
                        //性别
                        mTvCurrentCustomerSex.setText(choose_list.getCustomer_sex());
                        //证件类型
                        mTvCurrentCertificateType.setText(choose_list.getCertificate_type());
                        //征信状况
                        mTvCurrentPeasonCredit.setText(choose_list.getPeason_credit());
                        //是否失信
                        mTvCurrentPeasonCrediless.setText(choose_list.getPeason_crediless());
                        //是否被执行
                        mTvCurrentPeasonEnforced.setText(choose_list.getPeason_enforced());
//                        if (!mMatesRequests.contains(mRemarryCurrentRequest)) {
//                            mMatesRequests.add(mRemarryCurrentRequest);
//                        }
                        mTextChangeListener201 = new TextChangeListener201(matesEntity);
                        mTextChangeListener202 = new TextChangeListener202(matesEntity);
                        mTextChangeListener203 = new TextChangeListener203(matesEntity);
                        mEtCurrentCustomerName.addTextChangedListener(mTextChangeListener201);
                        mEtCurrentCertificateNumber.addTextChangedListener(mTextChangeListener202);
                        mEtCurrentMobilePhone.addTextChangedListener(mTextChangeListener203);
                        mEtCurrentCustomerName.setTag(mTextChangeListener201);
                        mEtCurrentCertificateNumber.setTag(mTextChangeListener202);
                        mEtCurrentMobilePhone.setTag(mTextChangeListener203);
                        break;
                }
            } else if ("2".equals(relationship_type)) {//前任
                String[] excludsArray = new String[]{"choose_list", "id"};
                switch (mType) {
                    case 3://再婚前任
//                        try {
//                            Properties.copyPropertiesExclude(matesEntity, mRemarrypredecessorRequest, excludsArray);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                        mRemarrypredecessor = matesEntity;
                        //姓名
                        mEtPredecessorCustomerName.setText(matesEntity.getCustomer_name());
                        //证件号码
                        mEtPredecessorCertificateNumber.setText(matesEntity.getCertificate_number());
                        //证件号码
                        mEtPredecessorMobilePhone.setText(matesEntity.getMobile_phone());
                        //性别
                        mTvPredecessorCustomerSex.setText(choose_list.getCustomer_sex());
                        //证件类型
                        mTvPredecessorCertificateType.setText(choose_list.getCertificate_type());
                        //征信状况
                        mTvPredecessorPeasonCredit.setText(choose_list.getPeason_credit());
                        //是否失信
                        mTvPredecessorPeasonCrediless.setText(choose_list.getPeason_crediless());
                        //是否被执行
                        mTvPredecessorPeasonEnforced.setText(choose_list.getPeason_enforced());
//                        if (!mMatesRequests.contains(mRemarrypredecessorRequest)) {
//                            mMatesRequests.add(mRemarrypredecessorRequest);
//                        }
                        mTextChangeListener301 = new TextChangeListener301(matesEntity);
                        mTextChangeListener302 = new TextChangeListener302(matesEntity);
                        mTextChangeListener303 = new TextChangeListener303(matesEntity);
                        mEtPredecessorCustomerName.addTextChangedListener(mTextChangeListener301);
                        mEtPredecessorCertificateNumber.addTextChangedListener(mTextChangeListener302);
                        mEtPredecessorMobilePhone.addTextChangedListener(mTextChangeListener303);
                        mEtPredecessorCustomerName.setTag(mTextChangeListener301);
                        mEtPredecessorCertificateNumber.setTag(mTextChangeListener302);
                        mEtPredecessorMobilePhone.setTag(mTextChangeListener303);
                        break;
                    case 4://离异前任
//                        try {
//                            Properties.copyPropertiesExclude(matesEntity, mDivorcedRequest, excludsArray);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                        mDivorced = matesEntity;
                        //姓名
                        mEtDivorcedCustomerName.setText(matesEntity.getCustomer_name());
                        //证件号码
                        mEtDivorcedCertificateNumber.setText(matesEntity.getCertificate_number());
                        //证件号码
                        mEtDivorcedMobilePhone.setText(matesEntity.getMobile_phone());
                        //性别
                        mTvDivorcedCustomerSex.setText(choose_list.getCustomer_sex());
                        //证件类型
                        mTvDivorcedCertificateType.setText(choose_list.getCertificate_type());
                        //征信状况
                        mTvDivorcedPeasonCredit.setText(choose_list.getPeason_credit());
                        //是否失信
                        mTvDivorcedPeasonCrediless.setText(choose_list.getPeason_crediless());
                        //是否被执行
                        mTvDivorcedPeasonEnforced.setText(choose_list.getPeason_enforced());
//                        if (!mMatesRequests.contains(mDivorcedRequest)) {
//                            mMatesRequests.add(mDivorcedRequest);
//                        }
                        mTextChangeListener401 = new TextChangeListener401(matesEntity);
                        mTextChangeListener402 = new TextChangeListener402(matesEntity);
                        mTextChangeListener403 = new TextChangeListener403(matesEntity);
                        mEtDivorcedCustomerName.addTextChangedListener(mTextChangeListener401);
                        mEtDivorcedCertificateNumber.addTextChangedListener(mTextChangeListener402);
                        mEtDivorcedMobilePhone.addTextChangedListener(mTextChangeListener403);
                        mEtDivorcedCustomerName.setTag(mTextChangeListener401);
                        mEtDivorcedCertificateNumber.setTag(mTextChangeListener402);
                        mEtDivorcedMobilePhone.setTag(mTextChangeListener403);
                        break;
                }
            } else if ("3".equals(relationship_type)) {//配偶已逝世
                switch (mType) {
                    case 5:
//                        String[] excludsArray = new String[]{"choose_list", "id"};
//                        try {
//                            Properties.copyPropertiesExclude(matesEntity, mWidRequest, excludsArray);
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
                        mWid = matesEntity;
                        //姓名
                        mEtWidCustomerName.setText(matesEntity.getCustomer_name());
                        //证件号码
                        mEtWidCertificateNumber.setText(matesEntity.getCertificate_number());
                        //性别
                        mTvWidCustomerSex.setText(choose_list.getCustomer_sex());
                        //证件类型
                        mTvWidCertificateType.setText(choose_list.getCertificate_type());
                        //死亡证明
                        mTvWidDeathCertificateType.setText(choose_list.getDeath_certificate_type());
//                        if (!mMatesRequests.contains(mWidRequest)) {
//                            mMatesRequests.add(mWidRequest);
//                        }
                        mTextChangeListener501 = new TextChangeListener501(matesEntity);
                        mTextChangeListener502 = new TextChangeListener502(matesEntity);

                        mEtWidCustomerName.addTextChangedListener(mTextChangeListener501);
                        mEtWidCertificateNumber.addTextChangedListener(mTextChangeListener502);

                        mEtWidCustomerName.setTag(mTextChangeListener501);
                        mEtWidCertificateNumber.setTag(mTextChangeListener502);
                        break;
                }
            } else {

            }
        }
    }

    private void initView() {
        mView = LayoutInflater.from(mContext).inflate(R.layout.recycler_layout_mates, null);
        LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mView.setLayoutParams(params);
        addView(mView);
        ButterKnife.bind(this, mView);
        mTvMarriedTitle.setText(String.format(mContext.getString(R.string.format_married_title), titleType));
        mTvCurrentTitle.setText(String.format(mContext.getString(R.string.format_current_title), titleType));
        mTvPredecessorTitle.setText(String.format(mContext.getString(R.string.format_predecessor_title), titleType));
        mTvDivorcedTitle.setText(String.format(mContext.getString(R.string.format_divorced_title), titleType));
        mTvWidTitle.setText(String.format(mContext.getString(R.string.format_wid_title), titleType));
    }

    @OnClick({R.id.lly_married_customer_sex, R.id.lly_married_certificate_type, R.id.lly_married_peason_credit, R.id.lly_married_peason_crediless, R.id.lly_married_peason_enforced, R.id.lly_current_customer_sex, R.id.lly_current_certificate_type, R.id.lly_current_peason_credit, R.id.lly_current_peason_crediless, R.id.lly_current_peason_enforced, R.id.lly_predecessor_customer_sex, R.id.lly_predecessor_certificate_type, R.id.lly_predecessor_peason_credit, R.id.lly_predecessor_peason_crediless, R.id.lly_predecessor_peason_enforced, R.id.lly_predecessor, R.id.lly_divorced_customer_sex, R.id.lly_divorced_certificate_type, R.id.lly_divorced_peason_credit, R.id.lly_divorced_peason_crediless, R.id.lly_divorced_peason_enforced, R.id.lly_wid_customer_sex, R.id.lly_wid_certificate_type, R.id.lly_wid_death_certificate_type})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.lly_married_customer_sex:
                pickerType = 101;
                mPresenter.loadPickerViewData("sex_list", "性别");
                break;
            case R.id.lly_married_certificate_type:
                pickerType = 102;
                mPresenter.loadPickerViewData("certificate_type", "证件类型");
                break;
            case R.id.lly_married_peason_credit:
                pickerType = 103;
                mPresenter.loadPickerViewData("peason_credit", "征信状况");
                break;
            case R.id.lly_married_peason_crediless:
                pickerType = 104;
                mPresenter.loadPickerViewData("li_boolean", "是否失信");
                break;
            case R.id.lly_married_peason_enforced:
                pickerType = 105;
                mPresenter.loadPickerViewData("li_boolean", "是否被执行");
                break;
            case R.id.lly_current_customer_sex:
                pickerType = 201;
                mPresenter.loadPickerViewData("sex_list", "性别");
                break;
            case R.id.lly_current_certificate_type:
                pickerType = 202;
                mPresenter.loadPickerViewData("certificate_type", "证件类型");
                break;
            case R.id.lly_current_peason_credit:
                pickerType = 203;
                mPresenter.loadPickerViewData("peason_credit", "征信状况");
                break;
            case R.id.lly_current_peason_crediless:
                pickerType = 204;
                mPresenter.loadPickerViewData("li_boolean", "是否失信");
                break;
            case R.id.lly_current_peason_enforced:
                pickerType = 205;
                mPresenter.loadPickerViewData("li_boolean", "是否被执行");
                break;
            case R.id.lly_predecessor_customer_sex:
                pickerType = 301;
                mPresenter.loadPickerViewData("sex_list", "性别");
                break;
            case R.id.lly_predecessor_certificate_type:
                pickerType = 302;
                mPresenter.loadPickerViewData("certificate_type", "证件类型");
                break;
            case R.id.lly_predecessor_peason_credit:
                pickerType = 303;
                mPresenter.loadPickerViewData("peason_credit", "征信状况");
                break;
            case R.id.lly_predecessor_peason_crediless:
                pickerType = 304;
                mPresenter.loadPickerViewData("li_boolean", "是否失信");
                break;
            case R.id.lly_predecessor_peason_enforced:
                pickerType = 305;
                mPresenter.loadPickerViewData("li_boolean", "是否被执行");
                break;
            case R.id.lly_divorced_customer_sex:
                pickerType = 401;
                mPresenter.loadPickerViewData("sex_list", "性别");
                break;
            case R.id.lly_divorced_certificate_type:
                pickerType = 402;
                mPresenter.loadPickerViewData("certificate_type", "证件类型");
                break;
            case R.id.lly_divorced_peason_credit:
                pickerType = 403;
                mPresenter.loadPickerViewData("peason_credit", "征信状况");
                break;
            case R.id.lly_divorced_peason_crediless:
                pickerType = 404;
                mPresenter.loadPickerViewData("li_boolean", "是否失信");
                break;
            case R.id.lly_divorced_peason_enforced:
                pickerType = 405;
                mPresenter.loadPickerViewData("li_boolean", "是否被执行");
                break;
            case R.id.lly_wid_customer_sex:
                pickerType = 501;
                mPresenter.loadPickerViewData("sex_list", "性别");
                break;
            case R.id.lly_wid_certificate_type:
                pickerType = 502;
                mPresenter.loadPickerViewData("certificate_type", "证件类型");
                break;
            case R.id.lly_wid_death_certificate_type:
                pickerType = 503;
                mPresenter.loadPickerViewData("death_certificate_type", "死亡证明类型");
                break;
        }
    }


    /**
     * 针对Dilaog加载dialog加载弹窗
     *
     * @param title 提示文字
     */
    @Override
    public void showDialogLoading(String title) {

    }

    /**
     * 针对Dilaog隐藏加载dialiog
     */
    @Override
    public void hideDialogLoading() {

    }

    /**
     * Toast提示接口
     *
     * @param msg
     */
    @Override
    public void showTip(String msg) {
        ToastUtils.showShort(msg);
    }


    /**
     * 返回下拉框信息
     *
     * @param list
     * @param type
     */
    @Override
    public void returnPickerViewData(List<PickerEntity> list, String type) {
        switch (pickerType) {
            case 101:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mMarriedCurrent.getCustomer_sex(), list,
                        pickerEntity1 -> {
                            mMarriedCurrent.setCustomer_sex(pickerEntity1.getSign_id());
                            mTvMarriedCustomerSex.setText(pickerEntity1.getTitle());
                        });
                break;
            case 102:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mMarriedCurrent.getCertificate_type(), list,
                        pickerEntity1 -> {
                            mMarriedCurrent.setCertificate_type(pickerEntity1.getSign_id());
                            mTvMarriedCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
            case 103:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mMarriedCurrent.getPeason_credit(), list,
                        pickerEntity1 -> {
                            mMarriedCurrent.setPeason_credit(pickerEntity1.getSign_id());
                            mTvMarriedPeasonCredit.setText(pickerEntity1.getTitle());
                        });
                break;
            case 104:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mMarriedCurrent.getPeason_crediless(), list,
                        pickerEntity1 -> {
                            mMarriedCurrent.setPeason_crediless(pickerEntity1.getSign_id());
                            mTvMarriedPeasonCrediless.setText(pickerEntity1.getTitle());
                        });
                break;
            case 105:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mMarriedCurrent.getPeason_enforced(), list,
                        pickerEntity1 -> {
                            mMarriedCurrent.setPeason_enforced(pickerEntity1.getSign_id());
                            mTvMarriedPeasonEnforced.setText(pickerEntity1.getTitle());
                        });
                break;
            case 201:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarryCurrent.getCustomer_sex(), list,
                        pickerEntity1 -> {
                            mRemarryCurrent.setCustomer_sex(pickerEntity1.getSign_id());
                            mTvCurrentCustomerSex.setText(pickerEntity1.getTitle());
                        });
                break;
            case 202:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarryCurrent.getCertificate_type(), list,
                        pickerEntity1 -> {
                            mRemarryCurrent.setCertificate_type(pickerEntity1.getSign_id());
                            mTvCurrentCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
            case 203:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarryCurrent.getPeason_credit(), list,
                        pickerEntity1 -> {
                            mRemarryCurrent.setPeason_credit(pickerEntity1.getSign_id());
                            mTvCurrentPeasonCredit.setText(pickerEntity1.getTitle());
                        });
                break;
            case 204:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarryCurrent.getPeason_crediless(), list,
                        pickerEntity1 -> {
                            mRemarryCurrent.setPeason_crediless(pickerEntity1.getSign_id());
                            mTvCurrentPeasonCrediless.setText(pickerEntity1.getTitle());
                        });
                break;
            case 205:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarryCurrent.getPeason_enforced(), list,
                        pickerEntity1 -> {
                            mRemarryCurrent.setPeason_enforced(pickerEntity1.getSign_id());
                            mTvCurrentPeasonEnforced.setText(pickerEntity1.getTitle());
                        });
                break;
            case 301:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarrypredecessor.getCustomer_sex(), list,
                        pickerEntity1 -> {
                            mRemarrypredecessor.setCustomer_sex(pickerEntity1.getSign_id());
                            mTvPredecessorCustomerSex.setText(pickerEntity1.getTitle());
                        });
                break;
            case 302:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarrypredecessor.getCertificate_type(), list,
                        pickerEntity1 -> {
                            mRemarrypredecessor.setCertificate_type(pickerEntity1.getSign_id());
                            mTvPredecessorCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
            case 303:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarrypredecessor.getPeason_credit(), list,
                        pickerEntity1 -> {
                            mRemarrypredecessor.setPeason_credit(pickerEntity1.getSign_id());
                            mTvPredecessorPeasonCredit.setText(pickerEntity1.getTitle());
                        });
                break;
            case 304:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarrypredecessor.getPeason_crediless(), list,
                        pickerEntity1 -> {
                            mRemarrypredecessor.setPeason_crediless(pickerEntity1.getSign_id());
                            mTvPredecessorPeasonCrediless.setText(pickerEntity1.getTitle());
                        });
                break;
            case 305:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mRemarrypredecessor.getPeason_enforced(), list,
                        pickerEntity1 -> {
                            mRemarrypredecessor.setPeason_enforced(pickerEntity1.getSign_id());
                            mTvPredecessorPeasonEnforced.setText(pickerEntity1.getTitle());
                        });
                break;
            case 401:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mDivorced.getCustomer_sex(), list,
                        pickerEntity1 -> {
                            mDivorced.setCustomer_sex(pickerEntity1.getSign_id());
                            mTvDivorcedCustomerSex.setText(pickerEntity1.getTitle());
                        });
                break;
            case 402:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mDivorced.getCertificate_type(), list,
                        pickerEntity1 -> {
                            mDivorced.setCertificate_type(pickerEntity1.getSign_id());
                            mTvDivorcedCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
            case 403:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mDivorced.getPeason_credit(), list,
                        pickerEntity1 -> {
                            mDivorced.setPeason_credit(pickerEntity1.getSign_id());
                            mTvDivorcedPeasonCredit.setText(pickerEntity1.getTitle());
                        });
                break;
            case 404:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mDivorced.getPeason_crediless(), list,
                        pickerEntity1 -> {
                            mDivorced.setPeason_crediless(pickerEntity1.getSign_id());
                            mTvDivorcedPeasonCrediless.setText(pickerEntity1.getTitle());
                        });
                break;
            case 405:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mDivorced.getPeason_enforced(), list,
                        pickerEntity1 -> {
                            mDivorced.setPeason_enforced(pickerEntity1.getSign_id());
                            mTvDivorcedPeasonEnforced.setText(pickerEntity1.getTitle());
                        });
                break;
            case 501:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mWid.getCustomer_sex(), list,
                        pickerEntity1 -> {
                            mWid.setCustomer_sex(pickerEntity1.getSign_id());
                            mTvWidCustomerSex.setText(pickerEntity1.getTitle());
                        });
                break;
            case 502:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mWid.getCertificate_type(), list,
                        pickerEntity1 -> {
                            mWid.setCertificate_type(pickerEntity1.getSign_id());
                            mTvWidCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
            case 503:
                PickerViewHelper.showOnePickerView((Activity) mContext, type, mWid.getDeath_certificate_type(), list,
                        pickerEntity1 -> {
                            mWid.setDeath_certificate_type(pickerEntity1.getSign_id());
                            mTvWidDeathCertificateType.setText(pickerEntity1.getTitle());
                        });
                break;
        }
    }

    public List<MatesRequest> getMatesRequests() {
//        mMarriedCurrentRequest.setCustomer_name(mEtMarriedCustomerName.getText().toString().trim());
//        mMarriedCurrentRequest.setCertificate_number(mEtMarriedCertificateNumber.getText().toString().trim());
//        mMarriedCurrentRequest.setMobile_phone(mEtMarriedMobilePhone.getText().toString().trim());
//
//        mRemarryCurrentRequest.setCustomer_name(mEtCurrentCustomerName.getText().toString().trim());
//        mRemarryCurrentRequest.setCertificate_number(mEtCurrentCertificateNumber.getText().toString().trim());
//        mRemarryCurrentRequest.setMobile_phone(mEtCurrentMobilePhone.getText().toString().trim());
//
//        mRemarrypredecessorRequest.setCustomer_name(mEtPredecessorCustomerName.getText().toString().trim());
//        mRemarrypredecessorRequest.setCertificate_number(mEtPredecessorCertificateNumber.getText().toString().trim());
//        mRemarrypredecessorRequest.setMobile_phone(mEtPredecessorMobilePhone.getText().toString().trim());
//
//        mDivorcedRequest.setCustomer_name(mEtDivorcedCustomerName.getText().toString().trim());
//        mDivorcedRequest.setCertificate_number(mEtDivorcedCertificateNumber.getText().toString().trim());
//        mDivorcedRequest.setMobile_phone(mEtDivorcedMobilePhone.getText().toString().trim());
//
//        mWidRequest.setCustomer_name(mEtWidCustomerName.getText().toString().trim());
//        mWidRequest.setCertificate_number(mEtWidCertificateNumber.getText().toString().trim());
//        mMatesRequests.clear();
//        switch (mType) {
//            case 1:
//                break;
//            case 2:
//                mMatesRequests.add(mMarriedCurrentRequest);
//                break;
//            case 3:
//                mMatesRequests.add(mRemarryCurrentRequest);
//                mMatesRequests.add(mRemarrypredecessorRequest);
//                break;
//            case 4:
//                mMatesRequests.add(mDivorcedRequest);
//                break;
//            case 5:
//                mMatesRequests.add(mWidRequest);
//                break;
//            default:
//                break;
//        }
        return null;
    }

    public void destroy() {
        mPresenter.onDetached();
    }

    /**
     * 已婚现任
     */
    class TextChangeListener101 implements TextWatcher {

        MatesEntity entity;

        public TextChangeListener101(MatesEntity entity) {
            this.entity = entity;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCustomer_name(s.toString());
//            mMarriedCurrentRequest.setCustomer_name(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener102 implements TextWatcher {
        BaseViewHolder holder;
        MatesEntity entity;

        public TextChangeListener102(MatesEntity entity) {
            this.holder = holder;
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCertificate_number(s.toString());
//            mMarriedCurrentRequest.setCertificate_number(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener103 implements TextWatcher {
        BaseViewHolder holder;
        MatesEntity entity;

        public TextChangeListener103(MatesEntity entity) {
            this.holder = holder;
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setMobile_phone(s.toString());
//            mMarriedCurrentRequest.setMobile_phone(s.toString());

        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    /**
     * 再婚前任
     */
    class TextChangeListener301 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener301(MatesEntity entity) {
            this.entity = entity;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCustomer_name(s.toString());
//            mRemarrypredecessorRequest.setCustomer_name(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener302 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener302(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCertificate_number(s.toString());
//            mRemarrypredecessorRequest.setCertificate_number(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener303 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener303(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setMobile_phone(s.toString());
//            mRemarrypredecessorRequest.setMobile_phone(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    /**
     * 已婚现任
     */
    class TextChangeListener201 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener201(MatesEntity entity) {
            this.entity = entity;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCustomer_name(s.toString());
//            mRemarryCurrentRequest.setCustomer_name(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener202 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener202(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCertificate_number(s.toString());
//            mRemarryCurrentRequest.setCertificate_number(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener203 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener203(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setMobile_phone(s.toString());
//            mRemarryCurrentRequest.setMobile_phone(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    /**
     * 离异
     */
    class TextChangeListener401 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener401(MatesEntity entity) {
            this.entity = entity;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCustomer_name(s.toString());
//            mDivorcedRequest.setCustomer_name(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener402 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener402(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCertificate_number(s.toString());
//            mDivorcedRequest.setCertificate_number(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener403 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener403(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setMobile_phone(s.toString());
//            mDivorcedRequest.setMobile_phone(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    /**
     * 丧偶
     */
    class TextChangeListener501 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener501(MatesEntity entity) {
            this.entity = entity;
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCustomer_name(s.toString());
//            mWidRequest.setCustomer_name(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }

    class TextChangeListener502 implements TextWatcher {
        MatesEntity entity;

        public TextChangeListener502(MatesEntity entity) {
            this.entity = entity;

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            entity.setCertificate_number(s.toString());
//            mWidRequest.setCertificate_number(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    }
}
